<%@ page import="java.sql.*" %>
<%@ page import="com.dx.cms.dao.UserDao" %>
<%@ page import="com.dx.cms.domain.User" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Admin
  Date: 2023/11/10
  Time: 10:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    String username=request.getParameter("username");//获取接收的参数值
    String password=request.getParameter("password");
    UserDao dao=new UserDao();
    List<User> list=dao.checkLogin(username,password);
    if(list!=null&&list.size()>0){
        session.setAttribute("username",list.get(0).getUsername());
        session.setAttribute("real_name",list.get(0).getRealName());
        response.sendRedirect("index.jsp");
    }else{
        //response.sendRedirect("login.jsp");
        out.print("<script>alert('登录失败');location='login.jsp';</script>");
    }
%>
</body>
</html>
